package com.fr.report.web.ui;

import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.web.Repository;

public class CustomWidgetConfig extends AbstractWidgetConfig
{
  public static final String XML_TAG = "CWC";
  private String xType;
  private String jsPath;
  private String cssPath;

  public CustomWidgetConfig()
  {
  }

  public CustomWidgetConfig(String paramString)
  {
    this.xType = paramString;
  }

  public String getWidgetType()
  {
    return this.xType;
  }

  public void setWidgetType(String paramString)
  {
    this.xType = paramString;
  }

  public String getJSPath()
  {
    return this.jsPath;
  }

  public void setJSPath(String paramString)
  {
    this.jsPath = paramString;
  }

  public String getCssPath()
  {
    return this.cssPath;
  }

  public void setCssPath(String paramString)
  {
    this.cssPath = paramString;
  }

  public Widget toWidget()
  {
    return new Widget(this)
    {
      private final CustomWidgetConfig this$0;

      public String getXType()
      {
        return CustomWidgetConfig.access$000(this.this$0);
      }

      public boolean isEditor()
      {
        return true;
      }

      public String[] supportedEvents()
      {
        return new String[0];
      }

      public JSONObject createJSONConfig(, Repository paramRepository)
        throws JSONException
      {
        JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
        if (!(StringUtils.isBlank(CustomWidgetConfig.access$100(this.this$0))))
          localJSONObject.put("jspath", CustomWidgetConfig.access$100(this.this$0));
        if (!(StringUtils.isBlank(CustomWidgetConfig.access$200(this.this$0))))
          localJSONObject.put("csspath", CustomWidgetConfig.access$200(this.this$0));
        return localJSONObject;
      }
    };
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("CWC"))
      {
        String str2 = paramXMLableReader.getAttr("jsPath");
        if (str2 != null)
          this.jsPath = str2;
        str2 = paramXMLableReader.getAttr("cssPath");
        if (str2 != null)
          this.cssPath = str2;
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if ((StringUtils.isNotEmpty(this.jsPath)) || (StringUtils.isNotEmpty(this.cssPath)))
    {
      paramXMLPrintWriter.startTAG("CWC");
      if (StringUtils.isNotEmpty(this.jsPath))
        paramXMLPrintWriter.attr("jsPath", this.jsPath);
      if (StringUtils.isNotEmpty(this.cssPath))
        paramXMLPrintWriter.attr("cssPath", this.cssPath);
      paramXMLPrintWriter.end();
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof CustomWidgetConfig))
      return false;
    return ((ComparatorUtils.equals(((CustomWidgetConfig)paramObject).jsPath, this.jsPath)) && (ComparatorUtils.equals(((CustomWidgetConfig)paramObject).cssPath, this.cssPath)) && (ComparatorUtils.equals(((CustomWidgetConfig)paramObject).xType, this.xType)));
  }

  static String access$000(CustomWidgetConfig paramCustomWidgetConfig)
  {
    return paramCustomWidgetConfig.xType;
  }

  static String access$100(CustomWidgetConfig paramCustomWidgetConfig)
  {
    return paramCustomWidgetConfig.jsPath;
  }

  static String access$200(CustomWidgetConfig paramCustomWidgetConfig)
  {
    return paramCustomWidgetConfig.cssPath;
  }
}